'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 副本奖励
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');
var copyConf = require('../config/copyConf');
var randomUtil = require('../util/randomUtil');
var genRewardService = require('./genRewardService');

/**
 * 获取副本奖励
 * @param {[type]} reward_list [description]
 */
exports.getRandomRewardList = function (job_type, copy_id) {
    var carbon_random_reward_conf = copyConf.getCarbonRandomRewardConf(job_type, copy_id);
    var random_reward = randomUtil.sample(carbon_random_reward_conf);
    var reward_list = [];
    if (random_reward) {
        reward_list.push(genRewardService.generateReward(random_reward));
    }
    return reward_list;
};

exports.getFixRewardList = function (job_type, copy_id) {
    var reward_list = [];
    var carbon_reward_conf = copyConf.getCarbonFixRewardConf(job_type, copy_id);
    if (!!carbon_reward_conf) {
        _.each(carbon_reward_conf, function (reward_item) {
            reward_list.push(genRewardService.generateReward(reward_item));
        });
    }
    return reward_list;
};

exports.getFirstRewardList = function (job_type, copy_id) {
    var reward_list = [];
    var carbon_reward_conf = copyConf.getCarbonFirstRewardConf(job_type, copy_id);
    if (!!carbon_reward_conf) {
        if (carbon_reward_conf instanceof Array) {
            _.each(carbon_reward_conf, function (reward_item) {
                reward_list.push(genRewardService.generateReward(reward_item));
            });
        } else {
            reward_list.push(genRewardService.generateReward(carbon_reward_conf));
        }
    }
    return reward_list;
};
